using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace TraceMonitor
{
    static class Program
    {
        public const string CONFIG_IPADDRESS = "ipaddress";
        public const string CONFIG_PORT = "port";

        public const string APP_TITLE = "Trace Monitor";

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }

        public static string GetConfig(string strKey)
        {
            try
            {
                return System.Configuration.ConfigurationManager.AppSettings[strKey];              
            }
            catch { return string.Empty; }
        }

        public static void SetConfig(string strKey, string strValue)
        {
            try
            {
                System.Configuration.Configuration objConfiguration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);

                if (objConfiguration == null)
                    return;

                objConfiguration.AppSettings.Settings.Remove(strKey);
                objConfiguration.AppSettings.Settings.Add(strKey, strValue);
                objConfiguration.Save(System.Configuration.ConfigurationSaveMode.Modified);

                System.Configuration.ConfigurationManager.RefreshSection("appSettings");
            }
            catch { }
        }
    }
}